home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programmer's Power Pack / Delphi Volume 1.iso / e_to_l / enhlb100 / testfrm.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  2.1 KB  |  83 lines

  1. unit Testfrm;
  2.  
  3. interface
  4.  
  5. uses
  6.     SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.     Forms, Dialogs, StdCtrls, Enhlbox, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Panel1: TPanel;
  12.     MCEnhancedListBox1: TMCEnhancedListBox;
  13.     Label1: TLabel;
  14.     Label2: TLabel;
  15.     MCEnhancedListBox2: TMCEnhancedListBox;
  16.     Label3: TLabel;
  17.     Label4: TLabel;
  18.     Label5: TLabel;
  19.     Label6: TLabel;
  20.     procedure FormCreate(Sender: TObject);
  21.     procedure FormDestroy(Sender: TObject);
  22.     procedure MCEnhancedListBox1DrawItem(Control: TWinControl;
  23.       Index: Integer; Rect: TRect; State: TOwnerDrawState);
  24.   private
  25.     { Private declarations }
  26.     public
  27.     { Public declarations }
  28.   end;
  29.  
  30. var
  31.     Form1: TForm1;
  32.     Bmp: array[1..100] of TBitmap;
  33.     Bmps: integer;
  34.  
  35. implementation
  36.  
  37. {$R *.DFM}
  38.  
  39. procedure TForm1.FormCreate(Sender: TObject);
  40. const
  41.     NoGlyphs: PChar =
  42.         'Couldn''t find any glyphs for my list in C:\DELPHI\IMAGES\BUTTONS\ -' + #13#10 +
  43.         'you have to change the FormCrate procedure to include the correct path!';
  44. var
  45.     Res: integer;
  46.     SR: TSearchRec;
  47. begin
  48.     Res := FindFirst('C:\DELPHI\IMAGES\BUTTONS\ARR*.BMP', 0, SR);
  49.     while Res = 0 do
  50.         begin
  51.             inc(Bmps);
  52.             Bmp[Bmps] := TBitmap.Create;
  53.             Bmp[Bmps].LoadFromFile('C:\DELPHI\IMAGES\BUTTONS\' + SR.Name);
  54.             MCEnhancedListBox1.Items.Add(SR.Name + #9 + IntToStr(SR.Size));
  55.             Res := FindNext(SR);
  56.         end;
  57.     FindClose(SR);
  58.     if MCEnhancedListBox1.Items.Count = 0 then
  59.         Application.MessageBox(NoGlyphs, 'Error', MB_APPLMODAL or MB_ICONEXCLAMATION or MB_OK);
  60. end;
  61.  
  62. procedure TForm1.FormDestroy(Sender: TObject);
  63. var
  64.     i: integer;
  65. begin
  66.     for i := 1 to Bmps do
  67.         Bmp[i].Free;
  68. end;
  69.  
  70. procedure TForm1.MCEnhancedListBox1DrawItem(Control: TWinControl;
  71.     Index: Integer; Rect: TRect; State: TOwnerDrawState);
  72. begin
  73.     with Control as TMCEnhancedListBox, (Control as TMCEnhancedListBox).Canvas do
  74.         begin
  75.             FillRect(Rect);
  76.             Draw(Rect.Left + 10, Rect.Top, Bmp[Index + 1]);
  77.             TextOut(PartX[1], Rect.Top, PartString[Index, 1]);
  78.             TextOut(PartX[2], Rect.Top, PartString[Index, 2]);
  79.         end;
  80. end;
  81.  
  82. end.
  83.